package YOONA;

import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;

@WebServlet("/a")
public class a extends GenericServlet {

    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        servletResponse.setContentType("text/html");
        PrintWriter writer = servletResponse.getWriter();
        ServletContext servletContext = this.getServletContext();
        System.out.println(servletContext);
        writer.print(servletContext);
        Enumeration initParameterNames = servletContext.getInitParameterNames();
        while (initParameterNames.hasMoreElements()) {
            String o = (String)initParameterNames.nextElement();
            String initParameter = servletContext.getInitParameter(o);
            System.out.println(o + ":" + initParameter);

        }
        String contextPath = servletContext.getContextPath();
        String realPath = servletContext.getRealPath("/index.html");
        String realPath1 = servletContext.getRealPath("aaa/yoona.html");
        String realPath2 = servletContext.getRealPath("/aaa/yoona.html");
        writer.print("<br>"+realPath1);
        writer.print("<br>"+realPath2);

        writer.print("<br>"+realPath);
        writer.print("<br>"+contextPath);

        user user = new user("lisi",12);
        servletContext.setAttribute("userr",user);
        Object userr = servletContext.getAttribute("userr");
        writer.print(userr);

    }
}
